<?php

namespace Api;

use Resume, Input, Response, Mail, Job;

class ResumesController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 * GET /resumes
	 *
	 * @return Response
	 */
	public function index()
	{
		return Resume::all();
	}

	/**
	 * Show the form for creating a new resource.
	 * GET /resumes/create
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}

	/**
	 * Store a newly created resource in storage.
	 * POST /resumes
	 *
	 * @return Response
	 */
	public function store()
	{
		$data = Input::all();
		Resume::create($data);
        $data['job_name'] = Job::find($data['job_id'])->name;

        Mail::queue('emails.resume', $data, function($message) use ($data) {
            $message->to('wonh_hr@wonhparts.com')->subject($data['name'].' 在微信上投递的简历');
        });

		return Response::json(['message' => 'Add Successfully']);
	}

	/**
	 * Display the specified resource.
	 * GET /resumes/{id}
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		//
	}

	/**
	 * Show the form for editing the specified resource.
	 * GET /resumes/{id}/edit
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
	}

	/**
	 * Update the specified resource in storage.
	 * PUT /resumes/{id}
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}

	/**
	 * Remove the specified resource from storage.
	 * DELETE /resumes/{id}
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}

}